<h1>Some Simple Summaries</h1>

<div>
Index
<ul class="index summaries" id="summaries.html">
<li><a class="index" href="#type-with-underlyings">Types whose values may have indirect underlying parts</a>.</li>
<li><a class="index" href="#have-length-types">Types which values can be used as arguments of built-in <code>len</code> function
	(and <code>cap</code>, <code>close</code>, <code>delete</code>, <code>make</code> functions)</a>.</li>
<li><a class="index" href="#container-types">Comparison of built-in container types</a>.</li>
<li><a class="index" href="#composite-literals-types">Types which values can be represented with composite literals (<code>T{...}</code>)</a>.</li>
<li><a class="index" href="#type-sizes">Value sizes of all kinds of types</a>.</li>
<li><a class="index" href="#nil-zero-value-types">Types which zero values can be represented with <code>nil</code></a>.</li>
<li><a class="index" href="#types-can-have-methods">Types we can implement methods for</a>.</li>
<li><a class="index" href="#types-can-be-embedded">Types which can be embedded in struct types</a>.</li>
<li><a class="index" href="#compile-time-evaluation">Functions whose calls will/may be evaluated at compile time</a>.</li>
<li><a class="index" href="#not-addressable">Values that can't be taken addresses</a>.</li>
<li><a class="index" href="#not-comparable">Types which don't support comparisons</a>.</li>
<li><a class="index" href="#declared-but-unused">Which code elements are allowed to be declared but not used</a>.</li>
<li><a class="index" href="#groupable-elements">Named source code elements which can be declared together within <code>()</code></a>.</li>
<li><a class="index" href="#declaration-places">Named source code elements which can be declared both inside functions and outside any functions</a>.</li>
<li><a class="index" href="#additional-return">Expressions which evaluation results may contain optional additional values</a>.</li>
<li><a class="index" href="#block-forever">Ways to block the current goroutine ‎forever by using the channel mechanism</a>.</li>
<li><a class="index" href="#concatenate-strings">Ways to concatenate strings</a>.</li>
<li><a class="index" href="#compiler-optimizations">Optimizations made by the standard Go compiler</a>.</li>
<li><a class="index" href="#panic-cases">Run-time panic and crash cases</a>.</li>
</ul>



<p>
</p>

</div>

<div class="summaries-items">

<a class="anchor" id="type-with-underlyings"></a>
<h3>
	Types whose values may have indirect underlying parts
</h3>

<div>
Types whose values may have indirect underlying parts:
<ul>
<li>string types</li>
<li>function types</li>
<li>slice types</li>
<li>map types</li>
<li>channel types</li>
<li>interface types</li>
</ul>

<p>
The answer is based on the implementation of the standard Go compiler/runtime.
In fact, whether or not function values may have indirect underlying parts is hardly to prove,
and string values and interface values should be viewed as values without indirect underlying parts in logic.
Please read <a href="value-part.html">value parts</a> for details.
</p>
</div>

<a class="anchor" id="have-length-types"></a>
<h3>
	Types which values can be used as arguments of built-in <code>len</code> function
	(and <code>cap</code>, <code>close</code>, <code>delete</code>, <code>make</code> functions)
</h3>

<table border="1" class="table table-bordered text-center" style="width: auto !important;">
<thead>
	<tr>
	<th class="text-center" valign="bottom" align="center"></th>
	<th class="text-center" valign="bottom" align="center">len</th>
	<th class="text-center" valign="bottom" align="center">cap</th>
	<th class="text-center" valign="bottom" align="center">close</th>
	<th class="text-center" valign="bottom" align="center">delete</th>
	<th class="text-center" valign="bottom" align="center">make</th>
	</tr>
</thead>
<tbody>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">string</th>
	<td valign="middle" align="center">Yes</td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">array<br/>(and array pointer)</th>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	<td></td>
	<td></td>
	<td></td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">slice</th>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	<td></td>
	<td></td>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">map</th>
	<td valign="middle" align="center">Yes</td>
	<td></td>
	<td></td>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">channel</th>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	<td></td>
	<td valign="middle" align="center">Yes</td>
	</tr>
</tbody>
</table>

<p>
Values of above types can also be ranged over in for-range loops.
</p>

<p>
Types which values can be used as arguments of built-in function <code>len</code>
can be called container types in broad sense.
</p>

<a class="anchor" id="container-types"></a>
<h3>
	Comparison of built-in container types
</h3>

<table border="1" class="table table-bordered text-center" style="width: auto !important;">
<thead>
	<tr>
	<th class="text-center" valign="bottom" align="center">Type</th>
	<th class="text-center" valign="bottom" align="center">Can New Elements Be Added into Values?</th>
	<th class="text-center" valign="bottom" align="center">Are Elements of Values Replaceable?</th>
	<th class="text-center" valign="bottom" align="center">Are Elements of Values Addressable?</th>
	<th class="text-center" valign="bottom" align="center">Will Element Accesses Modify Value Lengths?</th>
	<th class="text-center" valign="bottom" align="center">May Values Have Underlying Parts</th>
	</tr>
</thead>
<tbody>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">string</th>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">Yes<sup>(1)</sup></td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">array</th>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">Yes<sup>(2)</sup></td>
	<td valign="middle" align="center">Yes<sup>(2)</sup></td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">No</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">slice</th>
	<td valign="middle" align="center">No<sup>(3)</sup></td>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">map</th>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">channel</th>
	<td valign="middle" align="center">Yes<sup>(4)</sup></td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">No</td>
	<td valign="middle" align="center">Yes</td>
	<td valign="middle" align="center">Yes</td>
	</tr>
</tbody>
</table>

<p>
<sup>(1)</sup> For the standard Go compiler/runtime.
<br/>
<sup>(2)</sup> For addressable array values only.
<br/>
<sup>(3)</sup> Generally, a slice value are modified by assigned another slice value to it by overwriting it.
Here, such cases are not viewed as "add new elements".
In fact, slice lengths can also be modified separately by calling the <code>reflect.SetLen</code> function.
Increase the length of a slice by this way is kind of adding new elements into the slice.
But the <code>reflect.SetLen</code> function is slow, so it is rarely used.
<br/>
<sup>(4)</sup> For buffered channels which are still not full.
</p>

<a class="anchor" id="composite-literals-types"></a>
<h3>
	Types which values can be represented with composite literals (<code>T{...}</code>)
</h3>

<p>
Values of the following four kinds of types can be represented with composite literals:
</p>

<table border="1" class="table table-bordered text-center" style="width: auto !important;">
<thead>
	<tr>
	<th class="text-center" valign="bottom" align="center">Type (<code>T</code>)</th>
	<th class="text-center" valign="bottom" align="center">Is <code>T{}</code> a Zero Value of <code>T</code>?</th>
	</tr>
</thead>
<tbody>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">struct</th>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">array</th>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">slice</th>
	<td valign="middle" align="center">No<br/>(zero value is <code>nil</code>)</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">map</th>
	<td valign="middle" align="center">No<br/>(zero value is <code>nil</code>)</td>
	</tr>
</tbody>
</table>

<a class="anchor" id="type-sizes"></a>
<h3>
	Value sizes of all kinds of types
</h3>

<p>
Please read <a href="value-copy-cost.html">value copy cost</a> for details.
</p>

<a class="anchor" id="nil-zero-value-types"></a>
<h3>
	Types which zero values can be represented with <code>nil</code>
</h3>

<p>
The zero values of the following types can be represented with <code>nil</code>.
</p>

<table border="1" class="table table-bordered text-center" style="width: auto !important;">
<thead>
	<tr>
	<th class="text-center" valign="bottom" align="center">Type (<code>T</code>)</th>
	<th class="text-center" valign="bottom" align="center">Size of <code>T(nil)</code></th>
	</tr>
</thead>
<tbody>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">pointer</th>
	<td valign="middle" align="center">1 word</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">slice</th>
	<td valign="middle" align="center">3 words</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">map</th>
	<td valign="middle" align="center">1 word</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">channel</th>
	<td valign="middle" align="center">1 word</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">function</th>
	<td valign="middle" align="center">1 word</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">interface</th>
	<td valign="middle" align="center">2 words</td>
	</tr>
</tbody>
</table>

<p>
The above listed sizes are for the standard Go compiler.
One word means 4 bytes on 32-bit architectures and 8 bytes on 64-bit architectures.
and <a href="value-part.html">the indirect underlying parts</a>
of a value don't contribute to the size of the value.
</p>

<p>
The size of a zero value of a type is the same as any other values of the same type.
</p>

<a class="anchor" id="types-can-have-methods"></a>
<h3>
	Types we can implement methods for
</h3>

<p>
Please read <a href="method.html">methods in Go</a> for details.
</p>

<a class="anchor" id="types-can-be-embedded"></a>
<h3>
	Types which can be embedded in struct types
</h3>

<p>
Please read <a href="type-embedding.html#embeddable-types">which types
can be embedded</a> for details.
</p>

<a class="anchor" id="compile-time-evaluation"></a>
<h3>
	Functions whose calls will/may be evaluated at compile time
</h3>

<p>
If a function call is evaluated at compile time,
its return results must be constants.
</p>

<table border="1" class="table table-bordered text-center" style="width: auto !important;">
<thead>
	<tr>
	<th class="text-center" valign="bottom" align="center">Function</th>
	<th class="text-center" valign="bottom" align="center">Return Type</th>
	<th class="text-center" valign="bottom" align="center">Are Calls Always Evaluated at Compile Time?</th>
	</tr>
</thead>
<tbody>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">unsafe.Sizeof</th>
	<td rowspan="3" style="vertical-align: middle" valign="middle" align="center"><code>uintptr</code></td>
	<td rowspan="3" style="vertical-align: middle" valign="middle" align="center">Yes, always.</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">unsafe.Alignof</th>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">unsafe.Offsetof</th>
	</tr>
	<tr>
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center"><br/><br/>len<br/><br/><br/></th>
	<td rowspan="2" style="vertical-align: middle" valign="middle" align="center"><code>int</code></td>
	<td rowspan="2" valign="middle" align="center">
		Not always.
		<br/><br/>
		<div class="text-left">
		From <a href="https://golang.org/ref/spec#Length_and_capacity">Go specification</a>:
		<ul>
		<li>
		the expression <code>len(s)</code> is constant if <code>s</code> is a string constant.
		</li>
		<li>
		the expressions <code>len(s)</code> and <code>cap(s)</code> are constants
		if the type of <code>s</code> is an array or pointer to an array
		and the expression <code>s</code> does not contain channel receives or (non-constant) function calls.
		</li>
		</ul>
		</div>
	</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center"><br/><br/>cap<br/><br/><br/></th>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center"><br/>real<br/><br/></th>
	<td rowspan="2" style="vertical-align: middle" valign="middle" align="center">
		The result is an untyped value. Its default type is <code>float64</code>.
	</td>
	<td rowspan="2" valign="middle" align="center">
		Not always.
		<br/><br/>
		<div class="text-left">
		From <a href="https://golang.org/ref/spec#Constants">Go spec</a>:
		the expressions <code>real(s)</code> and <code>imag(s)</code> are constants
		if <code>s</code> is a complex constant.
		</div>
	</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center"><br/>imag<br/><br/></th>
	</tr>
	<tr>
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">complex</th>
	<td style="vertical-align: middle" valign="middle" align="center">
		The result is an untyped value. Its default type is <code>complex128</code>.
	</td>
	<td valign="middle" align="center">
		Not always.
		<br/><br/>
		<div class="text-left">
		From <a href="https://golang.org/ref/spec#Constants">Go spec</a>:
		the expression <code>complex(sr, si)</code> is constant
		if both <code>sr</code> and <code>si</code> are numeric constants.
		</div>
	</td>
	</tr>
</tbody>
</table>

<a class="anchor" id="not-addressable"></a>
<h3>
	Addressable and unaddressable values
</h3>

<p>
Please read <a href="unofficial-faq.html#unaddressable-values">this FAQ item</a>
to get which values are addressable or unaddressable.
</p>

<a class="anchor" id="not-comparable"></a>
<h3>
	Types which don't support comparisons
</h3>

<p>
Please read <a href="unofficial-faq.html#incomparable-types">this FAQ item</a>
to get which values are addressable or unaddressable.
</p>

<a class="anchor" id="declared-but-unused"></a>
<h3>
	Which code elements are allowed to be declared but not used
</h3>

<table border="1" class="table table-bordered text-center" style="width: auto !important;">
<thead>
	<tr>
	<th class="text-center" valign="bottom" align="center"></th>
	<th class="text-center" valign="bottom" align="center">Allowed to Be Declared but Not Used?</th>
	</tr>
</thead>
<tbody>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">import</th>
	<td valign="middle" align="center">No</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">type</th>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">variable</th>
	<td valign="middle" align="center">
		Yes for package-level variables.
		<br/>
		No for local variables (for the standard compiler).
	</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">constant</th>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" valign="middle" align="center">function</th>
	<td valign="middle" align="center">Yes</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" valign="middle" align="center">label</th>
	<td valign="middle" align="center">No</td>
	</tr>
</tbody>
</table>

<a class="anchor" id="groupable-elements"></a>
<h3>
	Named source code elements which can be declared together within <code>()</code>
</h3>

<div>
Following source code elements (of the same kind) can be declared together within <code>()</code>:
<ul>
<li>import</li>
<li>type</li>
<li>variable</li>
<li>constant</li>
</ul>
</div>
<p>
Functions can't be declared together within <code>()</code>. Also labels.
</p>

<a class="anchor" id="declaration-places"></a>
<h3>
	Named source code elements which can be declared both inside functions and outside any functions
</h3>

<div>
Following named source code elements can be declared both inside functions and outside any functions:
<ul>
<li>type</li>
<li>variable</li>
<li>constant</li>
</ul>
</div>
<p>
Imports must be declared before declarations of other elements (and after the package clause).
</p>
<p>
Functions can only be declared outside any functions.
Anonymous functions can be defined inside other function bodies,
but such definitions are not function declarations.
</p>
<p>
Labels must be declared inside functions.
</p>

<a class="anchor" id="additional-return"></a>
<h3>
	Expressions which evaluation results may contain optional additional values
</h3>

<p>
The evaluation results of the following expressions may contain optional additional values:
</p>

<table border="1" class="table table-bordered text-center" style="width: auto !important;">
<thead>
	<tr>
	<th class="text-center" valign="bottom" align="center"></th>
	<th class="text-center" valign="bottom" align="center">Syntax</th>
	<th class="text-center" valign="bottom" align="center">Meaning of The Optional Value (<code>ok</code> in the syntax examples)</th>
	<th class="text-center" valign="bottom" align="center">Will Omitting the Optional Result Affect Program Behavior?</th>
	</tr>
</thead>
<tbody>
	<tr class="active">
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">map element access</th>
	<td style="vertical-align: middle; white-space: nowrap;" class="text-center" valign="middle" align="center">
		<code>e, ok = aMap[key]</code>
	</td>
	<td valign="middle" align="center">whether or not the accessed key is present in the map</td>
	<td valign="middle" align="center">No</td>
	</tr>
	<tr>
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">channel value receive</th>
	<td style="vertical-align: middle; white-space: nowrap;" class="text-center" valign="middle" align="center">
		<code>e, ok = &lt;- aChannel</code>
	</td>
	<td valign="middle" align="center">whether or not the received value was sent before the channel was closed</td>
	<td valign="middle" align="center">No</td>
	</tr>
	<tr class="active">
	<th scope="row" class="text-center" style="vertical-align: middle" valign="middle" align="center">type assertion</th>
	<td style="vertical-align: middle; white-space: nowrap;" class="text-center" valign="middle" align="center">
		<code>v, ok = anInterface.(T)</code>
	</td>
	<td valign="middle" align="center">whether or not the dynamic type of the interface value matches the asserted type</td>
	<td valign="middle" align="center">Yes<br/>(when the optional bool result is omitted,
		a panic occurs if the assertion fails.)</td>
	</tr>
</tbody>
</table>

<a class="anchor" id="block-forever"></a>
<h3>
	Ways to block the current goroutine ‎forever by using the channel mechanism
</h3>

<div>
Without importing any package, we can use the following ways to make the current goroutine ‎enter (and stay in) blocking state forever:
<ol>
<li>send a value to a channel which no ones will receive values from
	<div>
<pre class="disable-line-numbers111"><code class="language-go">make(chan struct{}) <- struct{}{}
// or
make(chan<- struct{}) <- struct{}{}
</code></pre>
	</div>
</li>
<li>receive a value from a never-closed channel which no values have been and will be sent to
	<div>
<pre class="disable-line-numbers111"><code class="language-go"><-make(chan struct{})
// or
<-make(<-chan struct{})
// or
for range make(<-chan struct{}) {}
</code></pre>
	</div>
</li>
<li>receive a value from (or send a value to) a nil channel
	<div>
<pre class="disable-line-numbers111"><code class="language-go">chan struct{}(nil) <- struct{}{}
// or
<-chan struct{}(nil)
// or
for range chan struct{}(nil) {}
</code></pre>
	</div>
</li>
<li>use a bare select block
	<div>
<pre class="disable-line-numbers111"><code class="language-go">select{}
</code></pre>
	</div>
</li>
</ol>
</div>

<a class="anchor" id="concatenate-strings"></a>
<h3>
	Ways to concatenate strings
</h3>

<p>
Please read <a href="string.html#string-concatenation">strings in Go</a> for details.
</p>

<a class="anchor" id="compiler-optimizations"></a>
<h3>
	Optimizations made by the standard Go compiler
</h3>

<p>
Please read <a href="https://github.com/go101/go101/wiki/The-perceivable-optimizations-made-by-the-standard-Go-compiler-%28gc%29">the Go 101 wiki article</a> for this summary.
</p>

<a class="anchor" id="panic-cases"></a>
<h3>
	Run-time panic and crash cases
</h3>

<p>
Please read <a href="https://github.com/go101/go101/wiki/Panic-and-crash-cases">the Go 101 wiki article</a> for this summary.
</p>





</div> <!-- summaries-items -->

<!--

Fatal errors which can be recovered:
* https://play.golang.org/p/bYrfLTzXpc_o bad Mutex.Unlock call. unlock of unlocked lock
* create goroutine with nil function
* memory allcaotion fails, out of memory, alloc too large
* stack overflow
* map data race operation
  * concurrent map iteration and map write
  * concurrent map read and map write
  * concurrent map writes
* cgo callback before cgo call
* thread exhaustion
	package main
	import "runtime/debug"
	import "runtime"
	func main() {
		debug.SetMaxThreads(10)
		c := make(chan int)
		for i := 0; i < 100; i++ {
			go func() {
				runtime.LockOSThread()
				c <- 0
				select {}
			}()
			<-c
		}
	}
* load bad Go plugins
* all goroutines are blocked.
* string concatenation too long


short and standard variable declaration comparison

differences between built-in functions and custom functions.
  * generic
  * built-in function returns can't be omitted
  * built-in functions can't be used as values, they have no types.
  * built-in doon't need to be imported before using them, even their identifiers starts with lower..
  *

built-in function list

	"append":  predeclaredFunction,
	"cap":     predeclaredFunction,
	"close":   predeclaredFunction,
	"complex": predeclaredFunction,
	"copy":    predeclaredFunction,
	"delete":  predeclaredFunction,
	"imag":    predeclaredFunction,
	"len":     predeclaredFunction,
	"make":    predeclaredFunction,
	"new":     predeclaredFunction,
	"panic":   predeclaredFunction,
	"print":   predeclaredFunction,
	"println": predeclaredFunction,
	"real":    predeclaredFunction,
	"recover": predeclaredFunction,


#returns-discardable
return results of calls to which built-in functions can be discarded.

values of which kinds of types can be for-ranged.

ways to return a function: naturally return, return keyword, panic, runtime.Goexit()

the form <code>v[k]</code> can be used to access elements of values of which kinds of types?



-->

<!--
todo:
	kinds of control flow blocks
	control flow statements
		return, break, fallthrough, continue, goto
	which control flow statements can be followed a label.
	which control flow statements can appean in which control flow blocks

-->
